import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    name: "layout", path: '/', component: () => import('@/views/layout'),
    children: [
      { name: "index", path: '', component: () => import('@/views/home') },
      { name: "qa", path: '/qa', component: () => import('@/views/qa') },
      { name: "user", path: '/user', component: () => import('@/views/user') },
      { name: "video", path: '/video', component: () => import('@/views/video') }
    ]
  },
  { name: "login", path: '/login', component: () => import('@/views/login') },
  { name: "search", path: '/search', component: () => import('@/views/search') },
  { 
    name: "article", 
    path: '/article/:articleId', 
    component: () => import('@/views/article'),
    props:true  // 开启props传参，说白了将路由参数传递到组件的props中
  },
  { name: "userprofile", path: '/user/profile', component: () => import('@/views/user-profile') },
]
const router = new VueRouter({
  routes
})
export default router

